#!/usr/bin/perl -w

#=======================================================================
# strip_msgstr
# File ID: 8806a55c-5d45-11df-8c3b-90e6ba3022ac
# Stripper bort oversettelser i .po-filer for å se om det er noe grums 
# som har oppstått der.
#=======================================================================

use strict;

$| = 1;

use Getopt::Std;
our ($opt_h, $opt_o) =
    (     0,      0);
getopts('ho') || die("Option error. Use -h for help.\n");

$opt_h && usage(0);

my $Print = 1;

my $Keep = $opt_o ? "msgstr" : "msgid";
my $Strip = $opt_o ? "msgid" : "msgstr";

while (<>) {
    if (/^$Keep/ || /^$/) {
        $Print = 1;
    }
    elsif (/^$Strip/) {
        $Print = 0;
    }
    $Print && print;
}

sub usage {
    # Send the help message to stdout {{{
    my $Retval = shift;
    print(<<END);

Usage: strip_msgstr [options] [file [...]]

Strips translations from po files so potential nasty things can be 
found.

Options:

-o  Strip original text instead.

END
    exit($Retval);
    # }}}
}

# vim: set ts=4 sw=4 sts=4 et :
